home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nejlepší hry
/
Nejlepsi hry.iso
/
hry
/
sea of chaos
/
sea_install.msi
/
_15C39AAA7726369D39812BD40F01CF6A
/
_43E6F0B0FF2E4C8E8694244D0DF2B57B
< prev
next >
Wrap
Text File
|
2005-02-17
|
1KB
|
57 lines
//bird flap shader
//1 directional light and ambient light applied
//Luke Lenhart
//(C)2004-2005 Digipen Institute of Technology
//combined world,view,projection transform
float4x4 matWorldViewProj;
//1 directional light
float4 l1Direction;
float4 l1Color;
float4 lAmbient;
//current time (in seconds) since whenever
float time;
//shader input
struct VS_INPUT
{
float4 Pos : POSITION;
float4 Normal : NORMAL;
float2 Tex0 : TEXCOORD0;
};
//shader output
struct VS_OUTPUT
{
float4 Pos : POSITION;
float4 Color : COLOR;
float2 Tex0 : TEXCOORD0;
};
//shader code
VS_OUTPUT VShader(VS_INPUT In)
{
VS_OUTPUT Out;
//calc colors from directional light
float4 l1Contrib=dot(-In.Normal,l1Direction)*l1Color;
l1Contrib=saturate(l1Contrib);
Out.Color=l1Contrib + lAmbient;
Out.Color.a=1;
//oscillate position based on distance from the middle axis, to make the wing flap
float4 pos=In.Pos;
pos.z+=sin(time)*abs(In.Pos.y);
//do world/view/project transform
Out.Pos=mul(matWorldViewProj,pos);
//copy texture coord through
Out.Tex0=In.Tex0;
//spit out the results
return Out;
}